﻿using System;
using System.IO;
using System.Net;

namespace Klinkby
{
    using PodCaster.Properties;

    static class Http
    {
        public static void Get(Uri url, Action<Stream> command)
        {
            var req = (HttpWebRequest)WebRequest.Create(url);
            req.AutomaticDecompression = DecompressionMethods.Deflate;
            req.KeepAlive = true;
            req.AllowAutoRedirect = true;
            req.Accept = Resources.Accept;
            req.Headers.Add("Accept-Charset", Resources.AcceptCharset);
            req.Headers.Add("Accept-encoding", Resources.AcceptEncoding);
            req.UserAgent = Resources.UserAgent;
            req.Method = "GET";
            using (var res = (HttpWebResponse)req.GetResponse())
            {
                command(res.GetResponseStream());
            }
        }
    }
}
